import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import layout from '@/layout/index.vue'

import ArticleCreaterRouter from './modules/ArticleCreate'
import ArticleRouter from './modules/Article'
import PermissionListRouter from './modules/PermissionList'
import RoleListRouter from './modules/RoleList'
import UserManageRouter from './modules/UserManage'
import GdemoRouter from './modules/Gdemo'
import ScreenRouter from './modules/Screen'

// import CgRouter from './modules/Cg'
/**
 * 私有路由表
 */

export const privateRoutes = [
    RoleListRouter,
    UserManageRouter,
    PermissionListRouter,
    ArticleCreaterRouter,
    ArticleRouter,
    GdemoRouter,
    ScreenRouter,
    // CgRouter
]

/**
 * 公开路由表
 */
export const publicRoutes:Array<RouteRecordRaw> = [
    {
        path: '/login',
        component: () => import('@/views/cg/index.vue')
    },
    // {
    //     path: '/login',
    //     component: () => import('@/views/login/index.vue')
    // },
    {
         path: '/',
         // 注意：带有路径“/”的记录中的组件“默认”是一个不返回 Promise 的函数
         component: layout,
         redirect: '/profile',
         children: [
             {
                 path: '/profile',
                 name: 'profile',
                 component: () => import('@/views/profile/index.vue'),
                 meta: {
                     title: 'profile',
                     icon: 'personnel-info',
                     keepAlive:true // 默认是不需要写这个， 默认就是不缓存，需要keepalive的这个改为tree
                     // icon: 'el-icon-user'
                 }
             },
             {
                 path: '/404',
                 name: '404',
                 component: () => import('@/views/error-page/404.vue')
             },
             {
                 path: '/401',
                 name: '401',
                 component: () => import('@/views/error-page/401.vue')
             }
         ]
     }
]

const router = createRouter({
    history: createWebHashHistory(),
    routes: publicRoutes
})

export default router
